<%@ page language="java" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!doctype html>
<html lang="en">

<head>
	<title>Home</title>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<!-- VENDOR CSS -->
	<link rel="stylesheet" href="assets/vendor/bootstrap/css/bootstrap-datetimepicker.min.css">
	<link rel="stylesheet" href="assets/vendor/bootstrap/css/bootstrap-table.min.css">
	<link rel="stylesheet" href="assets/vendor/bootstrap/css/bootstrap-table.css">
	<link rel="stylesheet" href="assets/vendor/bootstrap/css/bootstrap.min.css">
	<link rel="stylesheet" href="assets/vendor/font-awesome/css/font-awesome.min.css">
	<link rel="stylesheet" href="assets/vendor/linearicons/style.css">
	<link rel="stylesheet" href="assets/vendor/chartist/css/chartist-custom.css">
	<!-- MAIN CSS -->
	<link rel="stylesheet" href="assets/css/main.css">
	<!-- FOR DEMO PURPOSES ONLY. You should remove this in your project -->
	<link rel="stylesheet" href="assets/css/demo.css">
	<!-- GOOGLE FONTS -->
	<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700" rel="stylesheet">
	<!-- ICONS -->
	<link rel="apple-touch-icon" sizes="76x76" href="assets/img/apple-icon.png">
	<link rel="icon" type="image/png" sizes="96x96" href="assets/img/favicon.png">
</head>

<body>
		
		<jsp:include page="/assets/jsp/header.jsp" flush="true"/>
		<jsp:include page="/assets/jsp/menu.jsp" flush="true"/>
		<!-- MAIN -->
		<div class="main">
			<!-- MAIN CONTENT -->
							<form role="form" id="searchForm" class="form-horizontal" style=" border:1px solid #006600">
                 <legend></legend>
                <fieldset>
                    <div class="form-group">
                        <label class="col-sm-2" for="subject_number">科目代号</label> 
                        <div class="col-sm-2">
                        	<input type="text"   class="form-control" id="subject_number" name="subject_number" style=" border:1px solid #006600" >
                        </div>
                        <label class="col-sm-2" for="subject_name">科目名称</label> 
                        <div class="col-sm-2">
                        	<input type="text"   class="form-control" id="subject_name" name="subject_name" style=" border:1px solid #006600" >
                        </div>
                        <label class="col-sm-2"  for="subject_type">科目类型</label>
                        <div class="col-sm-2">
                        <select id="subject_type"  name="subject_type" class="form-control">
                        	<option value="">请选择</option>
                        	<option value="01">资产类</option>
                        	<option value="02">负债类</option>
                        	<option value="03">损益类</option>
                        </select>
                        </div>
                     </div>
                     <div class="form-group">
                     	<label class="col-sm-2"  for="subject_level">科目级别</label>
                        <div class="col-sm-2">
	                        <select id="subject_level"  name="subject_level" class="form-control">
	                        	<option value="">请选择</option>
	                        	<option value="01">一类科目</option>
	                        	<option value="02">二类科目</option>
	                        	<option value="03">三类科目</option>
	                        </select>
                        </div>
                        <label class="col-sm-2"  for="subject_balance_direct">余额方向</label>
                        <div class="col-sm-2">
	                        <select id="subject_balance_direct"  name="subject_balance_direct" class="form-control">
	                        	<option value="">请选择</option>
	                        	<option value="D">借方</option>
	                        	<option value="C">贷方</option>
	                        	<option value="1">双向</option>
	                        </select>
                        </div>
                         <label class="col-sm-2"  for="subject_status">科目状态</label>
                        <div class="col-sm-2">
	                        <select id="subject_status"  name="subject_status" class="form-control">
	                        	<option value="">请选择</option>
	                        	<option value="1">正常</option>
	                        	<option value="0">作废</option>
	                        </select>
                        </div>
                    </div>
               </fieldset>
                    <div class="form-group">
                    	<div class="col-sm-1">
                    	<input type="button"  id="searchBtn" class="btn btn-default" value="开始搜索"/>
                    	</div>
                    	 <div class="col-sm-1">
                    	 <input type="button"  onclick="addTellerView();"  class="btn btn-default" value="增加柜员"/>
                    	 </div>
                    </div>
                </form>
                <legend></legend>
      			
				  <!--列表展示-->
     		<table id = "table"  data-filter-control="true"></table>
			<!-- END MAIN CONTENT -->
		</div>
		<!-- END MAIN -->
		<div class="clearfix">
		<footer>
			<div class="container-fluid">
				<p class="copyright">Copyright &copy; 2018.Company  Shanbrain-bankli  All rights reserved.More Templates </p>
			</div>
		</footer>
	 </div>
	<!-- END WRAPPER -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
    <div class="modal-dialog" style="width:600px;">
        <div class="modal-content" >
            <div class="modal-header">
            	<label>修改柜员信息</label>
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            </div>
            <form role="form" id="change_form" class="form-horizontal" style="border-right:40px solid #FFF;border-top:10px solid #FFF" >
			<div class="form-group">

				<label class="col-sm-3" for="change_subject_number" style="font-size:15px;text-align:right;"  >科目代号</label>
				<div class="col-sm-3">
					<input type="text" class="form-control" id="change_subject_number"
						name="subject_number"  />
				</div>
				<label class="col-sm-3" for="change_subject_name" style="font-size:15px;text-align:right;">科目名称</label>
				<div class="col-sm-3">
					<input type="text" class="form-control" id="change_subject_name"
						name="subject_name" >
				</div>
			</div>
			<div class="form-group">

				<label class="col-sm-3" for="change_subject_type" style="font-size:15px;text-align:right;">科目类型</label>
				<div class="col-sm-3">
					<select id="change_subject_type" name="subject_type"
						class="form-control">
						<option value="">请选择</option>
                        	<option value="01">资产类</option>
                        	<option value="02">负债类</option>
                        	<option value="03">损益类</option>
					</select>
				</div>
				<label class="col-sm-3" for="change_subject_level" style="font-size:15px;text-align:right;">科目级别</label>
				<div class="col-sm-3">
				<select id="change_subject_level" name="subject_level"
						class="form-control">
						<option value="">请选择</option>
                        	<option value="01">一类科目</option>
                        	<option value="02">二类科目</option>
                        	<option value="03">三类科目</option>
					</select>
				</div>
			</div>
			<div class="form-group">

				<label class="col-sm-3" for="change_super_subject" style="font-size:15px;text-align:right;">上级科目</label>
				<div class="col-sm-3">
					<input type="text" class="form-control" id="change_super_subject"
						name="organization"   />
				</div>
				<label class="col-sm-3" for="change_subject_balance_direct" style="font-size:15px;text-align:right;">余额方向</label>
				<div class="col-sm-3">
						<select id="change_subject_balance_direct" name="subject_balance_direct"
						class="form-control">
					<option value="">请选择</option>
	                        	<option value="D">借方</option>
	                        	<option value="C">贷方</option>
	                        	<option value="1">双向</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3" for="change_subject_status" style="font-size:15px;text-align:right;">科目状态</label>
				<div class="col-sm-3">
					<select id="change_subject_status" name="subject_status"
						class="form-control">
					<option value="">请选择</option>
	                        	<option value="">请选择</option>
	                        	<option value="1">正常</option>
	                        	<option value="0">作废</option>
					</select>
				</div>
			</div>
			<div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="change_submit();">提交更改</button>
            </div>
		</form>
            
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true" >
    <div class="modal-dialog" style="width:600px;">
        <div class="modal-content" >
            <div class="modal-header">
            	<label>新增柜员</label>
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            </div>
            <form role="form" id="addForm" class="form-horizontal" style="border-right:40px solid #FFF;border-top:10px solid #FFF" >
			<div class="form-group">

				<label class="col-sm-3" for="add_subject_number" style="font-size:15px;text-align:right;"  >科目代号</label>
				<div class="col-sm-3">
					<input type="text" class="form-control"  required="required" id="add_subject_number"
						name="subject_number"  />
				</div>
				<label class="col-sm-3" for="add_subject_name" style="font-size:15px;text-align:right;">科目名称</label>
				<div class="col-sm-3">
					<input type="text" class="form-control" id="add_subject_name"
						name="subject_name" required="required" >
				</div>
			</div>
			<div class="form-group">

				<label class="col-sm-3" for="add_subject_type" style="font-size:15px;text-align:right;">科目类型</label>
				<div class="col-sm-3">
					<select id="add_subject_type" name="subject_type"
						class="form-control" required="required">
						<option value="">请选择</option>
                        	<option value="01">资产类</option>
                        	<option value="02">负债类</option>
                        	<option value="03">损益类</option>
					</select>
				</div>
				<label class="col-sm-3" for="add_subject_level" style="font-size:15px;text-align:right;">科目级别</label>
				<div class="col-sm-3">
				<select id="add_subject_level" name="subject_level"
						class="form-control" required="required">
						<option value="">请选择</option>
                        	<option value="01">一类科目</option>
                        	<option value="02">二类科目</option>
                        	<option value="03">三类科目</option>
					</select>
				</div>
			</div>
			<div class="form-group">

				<label class="col-sm-3" for="add_super_subject" style="font-size:15px;text-align:right;">上级科目</label>
				<div class="col-sm-3">
					<input type="text" class="form-control" id="add_super_subject"
						name="organization"  required="required"/>
				</div>
				<label class="col-sm-3" for="add_subject_balance_direct" style="font-size:15px;text-align:right;">余额方向</label>
				<div class="col-sm-3">
						<select id="add_subject_balance_direct" name="subject_balance_direct"
						class="form-control"  required="required">
					<option value="">请选择</option>
	                        	<option value="D">借方</option>
	                        	<option value="C">贷方</option>
	                        	<option value="1">双向</option>
					</select>
				</div>
			</div>
			<div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
               <input type="submit" class="btn btn-default" data-dismiss="modal" value="提交"/>
                  <!--  <button type="button" class="btn btn-primary" onclick="addSubjectSubmit();" >提交</button>-->
            </div>
		</form>
            
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
	
	<!-- Javascript -->
	<script src="assets/vendor/jquery/jquery.min.js"></script>
	<script src="assets/vendor/bootstrap/js/bootstrap.min.js"></script>
	<script src="assets/vendor/jquery-slimscroll/jquery.slimscroll.min.js"></script>
	<script src="assets/vendor/jquery.easy-pie-chart/jquery.easypiechart.min.js"></script>
	<script src="assets/vendor/chartist/js/chartist.min.js"></script>
	<script src="assets/scripts/klorofil-common.js"></script>
		<script src="assets/scripts/common.js"></script>
	<script src="assets/scripts/bootstrap-datetimepicker.min.js"></script>
	<script src="assets/scripts/bootstrap-table.js"></script>
	<script src="assets/scripts/bootstrap-table-toolbar.js"></script>
<script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script>
	<script type="text/javascript">
	
	
	$("#subPages4").addClass("in");
	$(function () {
	    //1.初始化Table
	    var oTable = new TableInit();
	    oTable.Init();
	    //当点击查询按钮的时候执行
         $("#searchBtn").bind("click", oTable.Init);
	});
	var TableInit = function () {
	    var oTableInit = new Object();
	    //初始化Table
	    oTableInit.Init = function () {
	    	$("#table").bootstrapTable('destroy'); 
	    	$('#table').bootstrapTable({
	            url: '/brain-bank/getSubjectList.do',         //请求后台的URL（*）
	            method: 'post',                      //请求方式（*）
	            dataField : "data",
	            striped: true,                      //是否显示行间隔色
	            cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
	            pagination: true,                   //是否显示分页（*）
	            sortable: false,                     //是否启用排序
	            sortOrder: "asc",                   //排序方式
	            queryParams: oTableInit.queryParams,//传递参数（*）
	            sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
	            pageNumber:1,                       //初始化加载第一页，默认第一页
	            pageSize: 10,                       //每页的记录行数（*）
	            pageList: [10, 25],        //可供选择的每页的行数（*）
	            strictSearch: true,
	            minimumCountColumns: 2,             //最少允许的列数
	            clickToSelect: true,                //是否启用点击选中行
	            height: 500,                        //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
	            uniqueId: "number",                     //每一行的唯一标识，一般为主键列
	            cardView: false,                    //是否显示详细视图
	            detailView: false,                   //是否显示父子表
	            columns: [ {
                    field: 'subject_number',
                    title: '科目代号',
                    align: 'center' // 居中显示
                }, {
                    field: 'subject_name',
                    title: '科目名称',
                    align: 'center' // 居中显示
                }, {
                    field: 'subject_type',
                    title: '科目类型',
                    align: 'center', // 居中显示
               	   formatter:function(value,row,index){
                      	var subjecTypeName ="";
                      	if(value=="01")
                      		subjecTypeName = "资产类";
                      	else if(value=="02")
                      		subjecTypeName = "负债类";
                      	else
                      		subjecTypeName ="损益类";
                      	return subjecTypeName;
                      },
                      footerFormatter:"科目类型"
                }, {
                    field: 'subject_level',
                    title: '科目级别',
                    align: 'center',// 居中显示
                    formatter:function(value,row,index){
                    	var subjectLevelName ="";
                    	if(value=="01")
                    		subjectLevelName = "一类科目";
                    	else if(value=="02")
                    		subjectLevelName = "二类科目";
                    	else
                    		subjectLevelName ="三类科目";
                    	return subjectLevelName;
                    },
                    footerFormatter:"科目级别"
                }, {
                    field: 'super_subject',
                    title: '科目上级',
                    align: 'center' // 居中显示
                }, {
                    field: 'subject_balance_direct',
                    formatter:function(value,row,index){
                    	var tmp ="";
                    	if(value=="D")
                    		tmp = "借记";
                    	else if(value=="C")
                    		tmp = "贷记";
                       	else
                    		tmp = "双向";
                    	return tmp;
                    },
                    title: '余额方向',
                    align: 'center' // 居中显示
                }, {
                    field: 'subject_status',
                    formatter:function(value,row,index){
                    	var tmp ="";
                    	if(value=="1")
                    		tmp = "正常";
                    	else
                       		tmp =  "异常";
                    	return tmp;
                    },
                    title: '科目状态',
                    align: 'center' // 居中显示
                },  {
                	field: 'Button',
                	title: '操作',
                	events: operateEvents,
                	formatter: operateFormatter
                }]
	        });
	    };
	  //得到查询的参数
	    oTableInit.queryParams = function (params) {
	        var temp = {   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
        		pagecount: params.limit,   //页面大小
	            start: params.offset,  //页码
	            subject_number: $("#subject_number").val(),
	            subject_name: $("#subject_name").val(),
	            subject_type: $("#subject_type").val(),
	            subject_level: $("#subject_level").val(),
	            super_subject: $("#super_subject").val(),
	            subject_balance_direct: $("#subject_balance_direct").val(),
	            subject_status: $("#subject_status").val(),
	        };
	        return temp;
	    };
	    return oTableInit;
	};
	
	window.operateEvents={
			
	"click #tableEditor":function(e, value, row, index){
		$("#change_subject_number").val(row.subject_number);
		$("#change_subject_name").val(row.subject_name);
		$("#change_subject_type").val(row.subject_type);
		$("#change_subject_level").val(row.subject_level);
		$("#change_super_subject").val(row.super_subject);
		$("#change_subject_balance_direct").val(row.subject_balance_direct);
		$("#change_subject_status").val(row.subject_status);
		$('#myModal').modal('show');
	}
};
	
	function operateFormatter(value, row, index) {
		return [
			'<button id="tableEditor" type="button" class="RoleOfA btn-default bt-select">编辑</button>',
		].join('');
	}
	
	function change_submit(){
		var data = new Object();
		data.subject_number = $("#change_subject_number").val();
		data.subject_name = $("#change_subject_name").val();
		data.subject_type = $("#change_subject_type").val();
		data.subject_level = $("#change_subject_level").val();
		data.super_subject = $("#change_super_subject").val();
		data.subject_balance_direct = $("#change_subject_balance_direct").val();
		data.subject_status = $("#change_subject_status").val();
		$.ajax({
			type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: "/brain-bank/updateSubject.do" ,//url
            contentType : "application/json",
            data: JSON.stringify(data),
	 		success:function(){
       		 	$.MsgBox.Confirm("温馨提示", "科目信息修改成功", function(){ $('#myModal').modal('hide');location.reload();});
	 		},
	 		error: function(XMLHttpRequest, textStatus, errorThrown){
            	alert("执行失败");
                alert(XMLHttpRequest.status);
                alert(XMLHttpRequest.readyState);
                alert(textStatus);
             }
	 	});
	}
	
	
	function addTellerView(){
		$('#myModal1').modal('show');
	}
	
	$(document).ready(function () {
		  $("#addForm").validate({
			  onsubmit:true,// 是否在提交是验证
			　　onfocusout:false,// 是否在获取焦点时验证
			　　onkeyup :false,// 是否在敲击键盘时验证
			rules: {　　　　//规则
				　　subject_number: {　　//要对应相对应的input中的name属性
				　　　　required: true
				　　},
				　　subject_name: {
				　　　　required: true
				　　}
				},
				messages:{　　　　//验证错误信息
				　　subject_number: {
				　　　　required: "请输入用户名"
				　　　　},
				　　subject_name: {
				　　　　required: "请输入密码"
				　　}
				},
		    submitHandler: function(form) {
		    	alert("111");
		    	var data = new Object();
				data.subject_number = $("#add_subject_number").val();
				data.subject_name = $("#add_subject_name").val();
				data.subject_type = $("#add_subject_type").val();
				data.subject_level = $("#add_subject_level").val();
				data.super_subject = $("#add_super_subject").val();
				data.subject_balance_direct = $("#add_subject_balance_direct").val();
				data.subject_status = $("#add_subject_status").val();
				$.ajax({
					type: "POST",//方法类型
		            dataType: "json",//预期服务器返回的数据类型
		            url: "/brain-bank/addSubjet.do" ,//url
		            contentType : "application/json",
		            data: JSON.stringify(data),
			 		success:function(){
		       		 	$.MsgBox.Confirm("温馨提示", "科目信息增加成功", function(){ $('#myModal1').modal('hide');location.reload();});
			 		},
			 		error: function(XMLHttpRequest, textStatus, errorThrown){
		            	alert("执行失败");
		                alert(XMLHttpRequest.status);
		                alert(XMLHttpRequest.readyState);
		                alert(textStatus);
		             }
			 	});
		    }
		  });
		});
	
	/*function addSubjectSubmit(){
		var data = new Object();
		data.subject_number = $("#add_subject_number").val();
		data.subject_name = $("#add_subject_name").val();
		data.subject_type = $("#add_subject_type").val();
		data.subject_level = $("#add_subject_level").val();
		data.super_subject = $("#add_super_subject").val();
		data.subject_balance_direct = $("#add_subject_balance_direct").val();
		data.subject_status = $("#add_subject_status").val();
		$.ajax({
			type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: "/brain-bank/addSubjet.do" ,//url
            contentType : "application/json",
            data: JSON.stringify(data),
	 		success:function(){
       		 	$.MsgBox.Confirm("温馨提示", "科目信息增加成功", function(){ $('#myModal1').modal('hide');location.reload();});
	 		},
	 		error: function(XMLHttpRequest, textStatus, errorThrown){
            	alert("执行失败");
                alert(XMLHttpRequest.status);
                alert(XMLHttpRequest.readyState);
                alert(textStatus);
             }
	 	});
	}*/
	</script>
</body>

</html>
